package com.example.user.common;

import lombok.Data;

import java.io.Serializable;

@Data
public class R<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 返回的状态
     */
    private boolean status;

    /**
     * 返回的提示信息
     */
    private String message;

    /**
     * 返回的结果
     */
    private T data;


    /**
     * 方法成功返回的结果
     *
     * @param data
     * @param message
     * @return
     */
    public R<T> success(T data, String message) {
        this.message = message;
        this.status = true;
        this.data = data;
        return this;
    }


    /**
     * 方法失败返回的结果
     *
     * @param data
     * @param message
     * @return
     */
    public R<T> error(T data, String message) {
        this.message = message;
        this.status = false;
        this.data = data;
        return this;
    }

}
